﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ApartmanYonetim.Formlar
{
    public partial class UyeListesi : Form
    {
        public UyeListesi()
        {
            InitializeComponent();
        }

        Siniflar.Fonksiyon fn = new Siniflar.Fonksiyon();
        Siniflar.Veritabani vt = new Siniflar.Veritabani();
        string sorgu =  "SELECT U.ID,B.Adi AS 'Blok Adı',U.DaireNo AS 'Daire No',U.AdiSoyadi AS 'Adı Soyadı',U.CepTelefonu AS 'Cep Telefonu' ,U.EpostaAdresi AS 'Eposta Adresi' FROM Uyeler AS U JOIN Bloklar AS B ON B.ID = U.BlokID JOIN AidatGrubu AS AG ON AG.ID = U.AidatGrubuID ";
        private void UyeListesi_Load(object sender, EventArgs e)
        {
            fn.Listele(sorgu,dataGridView1);
        }

        private void txtAra_TextChanged(object sender, EventArgs e)
        {
            if (rbIsim.Checked == true)
            {
                sorgu += "WHERE U.AdiSoyadi LIKE '%" + txtAra.Text + "%'";
                fn.Listele(sorgu, dataGridView1);
            }
            else if (rbDaireNo.Checked == true)
            {
                sorgu += "WHERE U.DaireNo LIKE '%" + txtAra.Text + "%'";
                fn.Listele(sorgu, dataGridView1);
            }
            else if (rbTelefonNo.Checked == true)
            {
                sorgu += "WHERE U.CepTelefonu LIKE '%" + txtAra.Text + "%'";
                fn.Listele(sorgu, dataGridView1);
            }
        }

        private void btnSecileniDuzenle_Click(object sender, EventArgs e)
        {
            
        }

        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            string id = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["ID"].Value.ToString();
            Formlar.UyeDuzenle ud = new UyeDuzenle();
            ud.id = id;
            fn.TabOlustur(ud);
            this.Close();
        }



    }
}
